﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WCSY.MODEL;
using WCSY.BLL;

namespace ContractSystem.WebUI.Components.SystemMenus
{
    public partial class MenuTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //int parentid = Convert.ToInt32(Request["parentid"].ToString());
            //childNodes(parentid);
            //string parentname = Request["parentname"].ToString();
            //Guide_top.Controls.Add(new LiteralControl("<div id=\"Guide_toptext\">" + parentname + "</div>"));
        }
         public void childNodes(int parentid)
        {
            string sql = "select rightsid,parentid,rightsname,rightstype,rightsurl,remarks from mg_rights where parentid = " + Convert.ToInt32(parentid) + " and rightstype=1";
            List<Mg_right> rights = Mg_rightManager.GetMg_rightsBySql(sql) as List<Mg_right>;

            //childNode.SelectAction = TreeNodeSelectAction.Expand;

            foreach (Mg_right c in rights)
            {
                //TreeNode child = new TreeNode();
                //child.Text = c.Rightsname;
                //child.Value = c.Rightsid.ToString();

                Guide_box.Controls.Add(new LiteralControl("<div class=\"guideexpand\" onclick=\"Switch(this)\">"+c.Rightsname+"</div>"));//添加<div>标签

                Guide_box.Controls.Add(new LiteralControl("<div class=\"guide\">"));
                
                //childNode.ChildNodes.Add(child);
                ///child.ImageUrl = "~/image/folder1.gif";
                //if (!c.Rightsurl.Equals(""))
                //{
                //    child.NavigateUrl = "JAVAscript:openUrl('" + c.Rightsurl + "');";
                //}
                //child.NavigateUrl = c.Rightsurl;

                childNodesEx(c.Rightsid);
            }
        }

        public void childNodesEx(int parentid)
        {
            string sql = "select rightsid,parentid,rightsname,rightstype,rightsurl,remarks from mg_rights where parentid = " + parentid + " and rightstype=1";
            List<Mg_right> rights = Mg_rightManager.GetMg_rightsBySql(sql) as List<Mg_right>;

            //childNode.SelectAction = TreeNodeSelectAction.Expand;
            Guide_box.Controls.Add(new LiteralControl("<ul>"));
            foreach (Mg_right c in rights)
            {
                //TreeNode child = new TreeNode();
                //child.Text = c.Rightsname;
                //child.Value = c.Rightsid.ToString();
                Guide_box.Controls.Add(new LiteralControl("<li><a href=\""+c.Rightsurl+"\" target=\"main_right\">"+c.Rightsname+"</a></li>"));
   
            }
             Guide_box.Controls.Add(new LiteralControl("</ul>"));
            Guide_box.Controls.Add(new LiteralControl("</div>"));
        }

       
    }
}
